package com.hiwhitley.easy.day21;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by hiwhitley on 2016/9/20.
 */
public class IsomorphicStrings_205 {
    public boolean isIsomorphic(String s, String t) {
        if (s == null && t == null) {
            return true;
        } else if (s == null || t == null) {
            return false;
        } else if (s.length() == 0 && t.length() == 0) {
            return true;
        } else if (s.length() != t.length()) {
            return false;
        }
        Map m = new HashMap();
        for (Integer i = 0; i < s.length(); ++i)
            if (m.put(s.charAt(i), i) != m.put(t.charAt(i) + "", i))
                return false;
        return true;
    }
}
